<!--  -->
<template>
<div class='innexForm'>
  <el-form :model="formData" label-width="120" ref="formData" :disabled="true">
    <el-form-item label="水域编号：">
      <el-input v-model="formData.waterNo" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="水域名称：" prop='waterName'>
      <el-input v-model="formData.waterName" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="水深（m）：">
      <el-input v-model="formData.waterDepth" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="水域类型：">
      <el-select v-model="formData.waterType" placeholder="暂无内容">
        <el-option v-for="item in waterTypeOptions"
                            :key="item.id"
                            :value="item.code"
                            :label="item.name"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="负责人：" prop='personInChargeName'>
      <el-input v-model="formData.personInChargeName" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="联系方式：" prop='personInChargePhone'>
      <el-input v-model="formData.personInChargePhone" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="水域负责人身份号：" prop='personInChargeIdentity'>
      <el-input v-model="formData.personInChargeIdentity" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="危险等级：">
      <el-select v-model="formData.dangerLevel" placeholder="暂无内容">
        <el-option v-for="item in dangerLevelOptions"
                            :key="item.id"
                            :value="item.code"
                            :label="item.name"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="面积（m²）：" prop='waterArea'>
      <el-input v-model="formData.waterArea" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="是否有防范设施：">
      <el-select v-model="formData.waterSignStatus" placeholder="暂无内容">
        <el-option label="是" :value="1"></el-option>
        <el-option label="否" :value="0"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="经纬度"
                prop="longitude">
      <el-col :span="11">
        <el-input v-model="formData.longitude"
                  :disabled="true"
                  placeholder="经度"></el-input>
      </el-col>
      <el-col :span="2"
              style="text-align: center">-</el-col>
      <el-col :span="11">
        <el-input v-model="formData.latitude"
                  :disabled="true"
                  placeholder="纬度"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="图片：" class="spcialLabel" style="width:100%;display:block">
      <app-upload ref="appUpload" v-model="formData.pictureArr" ></app-upload>
    </el-form-item>
    <el-form-item label="街道/社区/网格：" prop="gridIdArr">
      <div class="block">
        <el-cascader
          placeholder="请选择"
          :options="options"
          filterable
          :props="gridIdProps"
          v-model="formData.gridIdArr">
        </el-cascader>
      </div>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import { getUserGridTree } from '@/utils/SessionDataUtil'
import AppUpload from '@/components/AppMultiUpload'
import {getWater} from '@/http/WaterApi'
import {getDictDataOption} from '@/utils/getDictDataOption'
export default {
// import引入的组件需要注入到对象中才能使用
  name: 'WarterForm',
  props: {
    detailForm: {
      type: Object,
      default: function () {
        return {
        }
      }
    }
  },
  components: {AppUpload},
  data () {
    // 这里存放数据
    return {
      formData: {},
      queryData: {},
      treeData: [],
      treeOption: [],
      caseLevelOption: [],
      caseTypeOption: [],
      waterTypeOptions: [],
      dangerLevelOptions: [],
      gridIdProps: {
        label: 'name',
        value: 'id'
      }
    }
  },
  // 方法集合
  methods: {
    getTreeData () {
      let gridTree = getUserGridTree()
      if (gridTree && gridTree instanceof Array) {
        this.treeData = gridTree
        this.treeOption = gridTree
      }
    },
    getDetail (data) {
      getWater(data.id).then(resp => {
        if (resp.code && resp.code === '200') {
          let data = resp.data
          this.formData = data
        }
      })
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {
    detailForm: {
      handler: function (data) {
        this.formData = JSON.parse(JSON.stringify(data))
        this.getDetail(this.formData)
      },
      deep: true,
      immediate: true
    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {
    this.getTreeData()
    this.waterTypeOptions = getDictDataOption('水域类型')
    this.dangerLevelOptions = getDictDataOption('危险等级')
  },
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {} // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped>

</style>
